<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>setStyle</title>
</head>

<body>
    <div id="test">点击下方按钮修改本元素字体颜色</div>
    <button type="button" class="btn" id="btn">点击我修改字体颜色</button>
    <script>
        const setStyle = (el, prop, val) => el.style[prop] = val;
        const btn = document.querySelector('#btn');
        const div = document.querySelector('#test');
        btn.addEventListener('click', () => setStyle(div, 'color', '#2396ef'))
    </script>
</body>

</html>